
/*
===============================================================================
                    EntitySpaces Studio by EntitySpaces, LLC
             Persistence Layer and Business Objects for Microsoft .NET
             EntitySpaces(TM) is a legal trademark of EntitySpaces, LLC
                          http://www.entityspaces.net
===============================================================================
EntitySpaces Version : 2012.1.0930.0
EntitySpaces Driver  : SQL
Date Generated       : 2016/3/22 1:32:29
===============================================================================
*/

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using System.Data;
using System.ComponentModel;
using System.Xml.Serialization;
using System.Runtime.Serialization;

using EntitySpaces.Core;
using EntitySpaces.Interfaces;
using EntitySpaces.DynamicQuery;



namespace yncTech.BusinessObjects
{
	/// <summary>
	/// Encapsulates the 'T_S_UserInfo' table
	/// </summary>

    [DebuggerDisplay("Data = {Debug}")]
	[Serializable]
	[DataContract]
	[KnownType(typeof(TSUserInfo))]	
	[XmlType("TSUserInfo")]
	public partial class TSUserInfo : esTSUserInfo
	{	
		[DebuggerBrowsable(DebuggerBrowsableState.RootHidden | DebuggerBrowsableState.Never)]
		protected override esEntityDebuggerView[] Debug
		{
			get { return base.Debug; }
		}

		override public esEntity CreateInstance()
		{
			return new TSUserInfo();
		}
		
		#region Static Quick Access Methods
		static public void Delete(System.Decimal userID)
		{
			var obj = new TSUserInfo();
			obj.UserID = userID;
			obj.AcceptChanges();
			obj.MarkAsDeleted();
			obj.Save();
		}

	    static public void Delete(System.Decimal userID, esSqlAccessType sqlAccessType)
		{
			var obj = new TSUserInfo();
			obj.UserID = userID;
			obj.AcceptChanges();
			obj.MarkAsDeleted();
			obj.Save(sqlAccessType);
		}
		#endregion

		
					
		
	
	}



    [DebuggerDisplay("Count = {Count}")]
	[Serializable]
	[CollectionDataContract]
	[XmlType("TSUserInfoCollection")]
	public partial class TSUserInfoCollection : esTSUserInfoCollection, IEnumerable<TSUserInfo>
	{
		public TSUserInfo FindByPrimaryKey(System.Decimal userID)
		{
			return this.SingleOrDefault(e => e.UserID == userID);
		}

		
		
		#region WCF Service Class
		
		[DataContract]
		[KnownType(typeof(TSUserInfo))]
		public class TSUserInfoCollectionWCFPacket : esCollectionWCFPacket<TSUserInfoCollection>
		{
			public static implicit operator TSUserInfoCollection(TSUserInfoCollectionWCFPacket packet)
			{
				return packet.Collection;
			}

			public static implicit operator TSUserInfoCollectionWCFPacket(TSUserInfoCollection collection)
			{
				return new TSUserInfoCollectionWCFPacket() { Collection = collection };
			}
		}
		
		#endregion
		
				
	}



    [DebuggerDisplay("Query = {Parse()}")]
	[Serializable]	
	public partial class TSUserInfoQuery : esTSUserInfoQuery
	{
		public TSUserInfoQuery():this("TSUserInfoQuery")
		{
		}
		public TSUserInfoQuery(string joinAlias)
		{
			this.es.JoinAlias = joinAlias;
		}	

		override protected string GetQueryName()
		{
			return "TSUserInfoQuery";
		}
		
					
	
		#region Explicit Casts
		
		public static explicit operator string(TSUserInfoQuery query)
		{
			return TSUserInfoQuery.SerializeHelper.ToXml(query);
		}

		public static explicit operator TSUserInfoQuery(string query)
		{
			return (TSUserInfoQuery)TSUserInfoQuery.SerializeHelper.FromXml(query, typeof(TSUserInfoQuery));
		}
		
		#endregion		
	}

	[DataContract]
	[Serializable]
	abstract public partial class esTSUserInfo : esEntity
	{
		public esTSUserInfo()
		{

		}
		
		#region LoadByPrimaryKey
		public virtual bool LoadByPrimaryKey(System.Decimal userID)
		{
			if(this.es.Connection.SqlAccessType == esSqlAccessType.DynamicSQL)
				return LoadByPrimaryKeyDynamic(userID);
			else
				return LoadByPrimaryKeyStoredProcedure(userID);
		}

		public virtual bool LoadByPrimaryKey(esSqlAccessType sqlAccessType, System.Decimal userID)
		{
			if (sqlAccessType == esSqlAccessType.DynamicSQL)
				return LoadByPrimaryKeyDynamic(userID);
			else
				return LoadByPrimaryKeyStoredProcedure(userID);
		}

		private bool LoadByPrimaryKeyDynamic(System.Decimal userID)
		{
			TSUserInfoQuery query = new TSUserInfoQuery();
			query.Where(query.UserID == userID);
			return this.Load(query);
		}

		private bool LoadByPrimaryKeyStoredProcedure(System.Decimal userID)
		{
			esParameters parms = new esParameters();
			parms.Add("UserID", userID);
			return this.Load(esQueryType.StoredProcedure, this.es.spLoadByPrimaryKey, parms);
		}
		#endregion
		
		#region Properties
		
		
		
		/// <summary>
		/// Maps to T_S_UserInfo.UserID
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Decimal? UserID
		{
			get
			{
				return base.GetSystemDecimal(TSUserInfoMetadata.ColumnNames.UserID);
			}
			
			set
			{
				if(base.SetSystemDecimal(TSUserInfoMetadata.ColumnNames.UserID, value))
				{
					OnPropertyChanged(TSUserInfoMetadata.PropertyNames.UserID);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_UserInfo.ThirdUnitID
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Decimal? ThirdUnitID
		{
			get
			{
				return base.GetSystemDecimal(TSUserInfoMetadata.ColumnNames.ThirdUnitID);
			}
			
			set
			{
				if(base.SetSystemDecimal(TSUserInfoMetadata.ColumnNames.ThirdUnitID, value))
				{
					this._UpToBFThirdUnitByThirdUnitID = null;
					this.OnPropertyChanged("UpToBFThirdUnitByThirdUnitID");
					OnPropertyChanged(TSUserInfoMetadata.PropertyNames.ThirdUnitID);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_UserInfo.UserName
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String UserName
		{
			get
			{
				return base.GetSystemString(TSUserInfoMetadata.ColumnNames.UserName);
			}
			
			set
			{
				if(base.SetSystemString(TSUserInfoMetadata.ColumnNames.UserName, value))
				{
					OnPropertyChanged(TSUserInfoMetadata.PropertyNames.UserName);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_UserInfo.DeptNo
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String DeptNo
		{
			get
			{
				return base.GetSystemString(TSUserInfoMetadata.ColumnNames.DeptNo);
			}
			
			set
			{
				if(base.SetSystemString(TSUserInfoMetadata.ColumnNames.DeptNo, value))
				{
					OnPropertyChanged(TSUserInfoMetadata.PropertyNames.DeptNo);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_UserInfo.Manager
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String Manager
		{
			get
			{
				return base.GetSystemString(TSUserInfoMetadata.ColumnNames.Manager);
			}
			
			set
			{
				if(base.SetSystemString(TSUserInfoMetadata.ColumnNames.Manager, value))
				{
					OnPropertyChanged(TSUserInfoMetadata.PropertyNames.Manager);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_UserInfo.Email
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String Email
		{
			get
			{
				return base.GetSystemString(TSUserInfoMetadata.ColumnNames.Email);
			}
			
			set
			{
				if(base.SetSystemString(TSUserInfoMetadata.ColumnNames.Email, value))
				{
					OnPropertyChanged(TSUserInfoMetadata.PropertyNames.Email);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_UserInfo.CreatedBy
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String CreatedBy
		{
			get
			{
				return base.GetSystemString(TSUserInfoMetadata.ColumnNames.CreatedBy);
			}
			
			set
			{
				if(base.SetSystemString(TSUserInfoMetadata.ColumnNames.CreatedBy, value))
				{
					OnPropertyChanged(TSUserInfoMetadata.PropertyNames.CreatedBy);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_UserInfo.CreatedTime
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.DateTime? CreatedTime
		{
			get
			{
				return base.GetSystemDateTime(TSUserInfoMetadata.ColumnNames.CreatedTime);
			}
			
			set
			{
				if(base.SetSystemDateTime(TSUserInfoMetadata.ColumnNames.CreatedTime, value))
				{
					OnPropertyChanged(TSUserInfoMetadata.PropertyNames.CreatedTime);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_UserInfo.LastUpdatedBy
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String LastUpdatedBy
		{
			get
			{
				return base.GetSystemString(TSUserInfoMetadata.ColumnNames.LastUpdatedBy);
			}
			
			set
			{
				if(base.SetSystemString(TSUserInfoMetadata.ColumnNames.LastUpdatedBy, value))
				{
					OnPropertyChanged(TSUserInfoMetadata.PropertyNames.LastUpdatedBy);
				}
			}
		}		
		
		/// <summary>
		/// Maps to T_S_UserInfo.LastUpdatedTime
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.DateTime? LastUpdatedTime
		{
			get
			{
				return base.GetSystemDateTime(TSUserInfoMetadata.ColumnNames.LastUpdatedTime);
			}
			
			set
			{
				if(base.SetSystemDateTime(TSUserInfoMetadata.ColumnNames.LastUpdatedTime, value))
				{
					OnPropertyChanged(TSUserInfoMetadata.PropertyNames.LastUpdatedTime);
				}
			}
		}		
		
		[CLSCompliant(false)]
		internal protected BFThirdUnit _UpToBFThirdUnitByThirdUnitID;
		#endregion	

		#region .str() Properties
		
		public override void SetProperties(IDictionary values)
		{
			foreach (string propertyName in values.Keys)
			{
				this.SetProperty(propertyName, values[propertyName]);
			}
		}
		
		public override void SetProperty(string name, object value)
		{
			esColumnMetadata col = this.Meta.Columns.FindByPropertyName(name);
			if (col != null)
			{
				if(value == null || value is System.String)
				{				
					// Use the strongly typed property
					switch (name)
					{							
						case "UserID": this.str().UserID = (string)value; break;							
						case "ThirdUnitID": this.str().ThirdUnitID = (string)value; break;							
						case "UserName": this.str().UserName = (string)value; break;							
						case "DeptNo": this.str().DeptNo = (string)value; break;							
						case "Manager": this.str().Manager = (string)value; break;							
						case "Email": this.str().Email = (string)value; break;							
						case "CreatedBy": this.str().CreatedBy = (string)value; break;							
						case "CreatedTime": this.str().CreatedTime = (string)value; break;							
						case "LastUpdatedBy": this.str().LastUpdatedBy = (string)value; break;							
						case "LastUpdatedTime": this.str().LastUpdatedTime = (string)value; break;
					}
				}
				else
				{
					switch (name)
					{	
						case "UserID":
						
							if (value == null || value is System.Decimal)
								this.UserID = (System.Decimal?)value;
								OnPropertyChanged(TSUserInfoMetadata.PropertyNames.UserID);
							break;
						
						case "ThirdUnitID":
						
							if (value == null || value is System.Decimal)
								this.ThirdUnitID = (System.Decimal?)value;
								OnPropertyChanged(TSUserInfoMetadata.PropertyNames.ThirdUnitID);
							break;
						
						case "CreatedTime":
						
							if (value == null || value is System.DateTime)
								this.CreatedTime = (System.DateTime?)value;
								OnPropertyChanged(TSUserInfoMetadata.PropertyNames.CreatedTime);
							break;
						
						case "LastUpdatedTime":
						
							if (value == null || value is System.DateTime)
								this.LastUpdatedTime = (System.DateTime?)value;
								OnPropertyChanged(TSUserInfoMetadata.PropertyNames.LastUpdatedTime);
							break;
					

						default:
							break;
					}
				}
			}
            else if (this.ContainsColumn(name))
            {
                this.SetColumn(name, value);
            }
			else
			{
				throw new Exception("SetProperty Error: '" + name + "' not found");
			}
		}		

		public esStrings str()
		{
			if (esstrings == null)
			{
				esstrings = new esStrings(this);
			}
			return esstrings;
		}

		sealed public class esStrings
		{
			public esStrings(esTSUserInfo entity)
			{
				this.entity = entity;
			}
			
	
			public System.String UserID
			{
				get
				{
					System.Decimal? data = entity.UserID;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.UserID = null;
					else entity.UserID = Convert.ToDecimal(value);
				}
			}
				
			public System.String ThirdUnitID
			{
				get
				{
					System.Decimal? data = entity.ThirdUnitID;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.ThirdUnitID = null;
					else entity.ThirdUnitID = Convert.ToDecimal(value);
				}
			}
				
			public System.String UserName
			{
				get
				{
					System.String data = entity.UserName;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.UserName = null;
					else entity.UserName = Convert.ToString(value);
				}
			}
				
			public System.String DeptNo
			{
				get
				{
					System.String data = entity.DeptNo;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.DeptNo = null;
					else entity.DeptNo = Convert.ToString(value);
				}
			}
				
			public System.String Manager
			{
				get
				{
					System.String data = entity.Manager;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.Manager = null;
					else entity.Manager = Convert.ToString(value);
				}
			}
				
			public System.String Email
			{
				get
				{
					System.String data = entity.Email;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.Email = null;
					else entity.Email = Convert.ToString(value);
				}
			}
				
			public System.String CreatedBy
			{
				get
				{
					System.String data = entity.CreatedBy;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.CreatedBy = null;
					else entity.CreatedBy = Convert.ToString(value);
				}
			}
				
			public System.String CreatedTime
			{
				get
				{
					System.DateTime? data = entity.CreatedTime;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.CreatedTime = null;
					else entity.CreatedTime = Convert.ToDateTime(value);
				}
			}
				
			public System.String LastUpdatedBy
			{
				get
				{
					System.String data = entity.LastUpdatedBy;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.LastUpdatedBy = null;
					else entity.LastUpdatedBy = Convert.ToString(value);
				}
			}
				
			public System.String LastUpdatedTime
			{
				get
				{
					System.DateTime? data = entity.LastUpdatedTime;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.LastUpdatedTime = null;
					else entity.LastUpdatedTime = Convert.ToDateTime(value);
				}
			}
			

			private esTSUserInfo entity;
		}
		
		[NonSerialized]
		private esStrings esstrings;		
		
		#endregion
		
		#region Housekeeping methods

		override protected IMetadata Meta
		{
			get
			{
				return TSUserInfoMetadata.Meta();
			}
		}

		#endregion		
		
		#region Query Logic

		public TSUserInfoQuery Query
		{
			get
			{
				if (this.query == null)
				{
					this.query = new TSUserInfoQuery();
					InitQuery(this.query);
				}

				return this.query;
			}
		}

		public bool Load(TSUserInfoQuery query)
		{
			this.query = query;
			InitQuery(this.query);
			return this.Query.Load();
		}
		
		protected void InitQuery(TSUserInfoQuery query)
		{
			query.OnLoadDelegate = this.OnQueryLoaded;
			
			if (!query.es2.HasConnection)
			{
				query.es2.Connection = ((IEntity)this).Connection;
			}			
		}

		#endregion
		
        [IgnoreDataMember]
		private TSUserInfoQuery query;		
	}



	[Serializable]
	abstract public partial class esTSUserInfoCollection : esEntityCollection<TSUserInfo>
	{
		#region Housekeeping methods
		override protected IMetadata Meta
		{
			get
			{
				return TSUserInfoMetadata.Meta();
			}
		}

		protected override string GetCollectionName()
		{
			return "TSUserInfoCollection";
		}

		#endregion		
		
		#region Query Logic

	#if (!WindowsCE)
		[BrowsableAttribute(false)]
	#endif
		public TSUserInfoQuery Query
		{
			get
			{
				if (this.query == null)
				{
					this.query = new TSUserInfoQuery();
					InitQuery(this.query);
				}

				return this.query;
			}
		}

		public bool Load(TSUserInfoQuery query)
		{
			this.query = query;
			InitQuery(this.query);
			return Query.Load();
		}

		override protected esDynamicQuery GetDynamicQuery()
		{
			if (this.query == null)
			{
				this.query = new TSUserInfoQuery();
				this.InitQuery(query);
			}
			return this.query;
		}

		protected void InitQuery(TSUserInfoQuery query)
		{
			query.OnLoadDelegate = this.OnQueryLoaded;
			
			if (!query.es2.HasConnection)
			{
				query.es2.Connection = ((IEntityCollection)this).Connection;
			}			
		}

		protected override void HookupQuery(esDynamicQuery query)
		{
			this.InitQuery((TSUserInfoQuery)query);
		}

		#endregion
		
		private TSUserInfoQuery query;
	}



	[Serializable]
	abstract public partial class esTSUserInfoQuery : esDynamicQuery
	{
		override protected IMetadata Meta
		{
			get
			{
				return TSUserInfoMetadata.Meta();
			}
		}	
		
		#region QueryItemFromName
		
        protected override esQueryItem QueryItemFromName(string name)
        {
            switch (name)
            {
				case "UserID": return this.UserID;
				case "ThirdUnitID": return this.ThirdUnitID;
				case "UserName": return this.UserName;
				case "DeptNo": return this.DeptNo;
				case "Manager": return this.Manager;
				case "Email": return this.Email;
				case "CreatedBy": return this.CreatedBy;
				case "CreatedTime": return this.CreatedTime;
				case "LastUpdatedBy": return this.LastUpdatedBy;
				case "LastUpdatedTime": return this.LastUpdatedTime;

                default: return null;
            }
        }		
		
		#endregion
		
		#region esQueryItems

		public esQueryItem UserID
		{
			get { return new esQueryItem(this, TSUserInfoMetadata.ColumnNames.UserID, esSystemType.Decimal); }
		} 
		
		public esQueryItem ThirdUnitID
		{
			get { return new esQueryItem(this, TSUserInfoMetadata.ColumnNames.ThirdUnitID, esSystemType.Decimal); }
		} 
		
		public esQueryItem UserName
		{
			get { return new esQueryItem(this, TSUserInfoMetadata.ColumnNames.UserName, esSystemType.String); }
		} 
		
		public esQueryItem DeptNo
		{
			get { return new esQueryItem(this, TSUserInfoMetadata.ColumnNames.DeptNo, esSystemType.String); }
		} 
		
		public esQueryItem Manager
		{
			get { return new esQueryItem(this, TSUserInfoMetadata.ColumnNames.Manager, esSystemType.String); }
		} 
		
		public esQueryItem Email
		{
			get { return new esQueryItem(this, TSUserInfoMetadata.ColumnNames.Email, esSystemType.String); }
		} 
		
		public esQueryItem CreatedBy
		{
			get { return new esQueryItem(this, TSUserInfoMetadata.ColumnNames.CreatedBy, esSystemType.String); }
		} 
		
		public esQueryItem CreatedTime
		{
			get { return new esQueryItem(this, TSUserInfoMetadata.ColumnNames.CreatedTime, esSystemType.DateTime); }
		} 
		
		public esQueryItem LastUpdatedBy
		{
			get { return new esQueryItem(this, TSUserInfoMetadata.ColumnNames.LastUpdatedBy, esSystemType.String); }
		} 
		
		public esQueryItem LastUpdatedTime
		{
			get { return new esQueryItem(this, TSUserInfoMetadata.ColumnNames.LastUpdatedTime, esSystemType.DateTime); }
		} 
		
		#endregion
		
	}


	
	public partial class TSUserInfo : esTSUserInfo
	{

				
		#region UpToBFThirdUnitByThirdUnitID - Many To One
		/// <summary>
		/// Many to One
		/// Foreign Key Name - FK_T_S_USER_REFERENCE_BF_THIRD
		/// </summary>

		[XmlIgnore]
					
		public BFThirdUnit UpToBFThirdUnitByThirdUnitID
		{
			get
			{
				if (this.es.IsLazyLoadDisabled) return null;
				
				if(this._UpToBFThirdUnitByThirdUnitID == null && ThirdUnitID != null)
				{
					this._UpToBFThirdUnitByThirdUnitID = new BFThirdUnit();
					this._UpToBFThirdUnitByThirdUnitID.es.Connection.Name = this.es.Connection.Name;
					this.SetPreSave("UpToBFThirdUnitByThirdUnitID", this._UpToBFThirdUnitByThirdUnitID);
					this._UpToBFThirdUnitByThirdUnitID.Query.Where(this._UpToBFThirdUnitByThirdUnitID.Query.ThirdUnitID == this.ThirdUnitID);
					this._UpToBFThirdUnitByThirdUnitID.Query.Load();
				}	
				return this._UpToBFThirdUnitByThirdUnitID;
			}
			
			set
			{
				this.RemovePreSave("UpToBFThirdUnitByThirdUnitID");
				

				if(value == null)
				{
					this.ThirdUnitID = null;
					this._UpToBFThirdUnitByThirdUnitID = null;
				}
				else
				{
					this.ThirdUnitID = value.ThirdUnitID;
					this._UpToBFThirdUnitByThirdUnitID = value;
					this.SetPreSave("UpToBFThirdUnitByThirdUnitID", this._UpToBFThirdUnitByThirdUnitID);
				}
				
			}
		}
		#endregion
		

		#region UpToTSUsers - One To One
		/// <summary>
		/// One to One
		/// Foreign Key Name - FK1_T_S_UserInfo_UserID
		/// </summary>

		[XmlIgnore]
		public TSUsers UpToTSUsers
		{
			get
			{
				if (this.es.IsLazyLoadDisabled) return null;
			
				if(this._UpToTSUsers == null && UserID != null)
				{
					this._UpToTSUsers = new TSUsers();
					this._UpToTSUsers.es.Connection.Name = this.es.Connection.Name;
					this.SetPreSave("UpToTSUsers", this._UpToTSUsers);
					this._UpToTSUsers.Query.Where(this._UpToTSUsers.Query.UserID == this.UserID);
					this._UpToTSUsers.Query.Load();
				}

				return this._UpToTSUsers;
			}
			
			set 
			{ 
				this.RemovePreSave("UpToTSUsers");

				if(value == null)
				{
					this._UpToTSUsers = null;
				}
				else
				{
					this._UpToTSUsers = value;
					this.SetPreSave("UpToTSUsers", this._UpToTSUsers);
				}
				
				
			} 
		}
				
		
		private TSUsers _UpToTSUsers;
		#endregion

		
		/// <summary>
		/// Used internally for retrieving AutoIncrementing keys
		/// during hierarchical PreSave.
		/// </summary>
		protected override void ApplyPreSaveKeys()
		{
			if(!this.es.IsDeleted && this._UpToBFThirdUnitByThirdUnitID != null)
			{
				this.ThirdUnitID = this._UpToBFThirdUnitByThirdUnitID.ThirdUnitID;
			}
			if(!this.es.IsDeleted && this._UpToTSUsers != null)
			{
				this.UserID = this._UpToTSUsers.UserID;
			}
		}
		
	}
	



	[Serializable]
	public partial class TSUserInfoMetadata : esMetadata, IMetadata
	{
		#region Protected Constructor
		protected TSUserInfoMetadata()
		{
			m_columns = new esColumnMetadataCollection();
			esColumnMetadata c;

			c = new esColumnMetadata(TSUserInfoMetadata.ColumnNames.UserID, 0, typeof(System.Decimal), esSystemType.Decimal);
			c.PropertyName = TSUserInfoMetadata.PropertyNames.UserID;
			c.IsInPrimaryKey = true;
			c.NumericPrecision = 18;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSUserInfoMetadata.ColumnNames.ThirdUnitID, 1, typeof(System.Decimal), esSystemType.Decimal);
			c.PropertyName = TSUserInfoMetadata.PropertyNames.ThirdUnitID;
			c.NumericPrecision = 18;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSUserInfoMetadata.ColumnNames.UserName, 2, typeof(System.String), esSystemType.String);
			c.PropertyName = TSUserInfoMetadata.PropertyNames.UserName;
			c.CharacterMaxLength = 50;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSUserInfoMetadata.ColumnNames.DeptNo, 3, typeof(System.String), esSystemType.String);
			c.PropertyName = TSUserInfoMetadata.PropertyNames.DeptNo;
			c.CharacterMaxLength = 100;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSUserInfoMetadata.ColumnNames.Manager, 4, typeof(System.String), esSystemType.String);
			c.PropertyName = TSUserInfoMetadata.PropertyNames.Manager;
			c.CharacterMaxLength = 50;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSUserInfoMetadata.ColumnNames.Email, 5, typeof(System.String), esSystemType.String);
			c.PropertyName = TSUserInfoMetadata.PropertyNames.Email;
			c.CharacterMaxLength = 40;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSUserInfoMetadata.ColumnNames.CreatedBy, 6, typeof(System.String), esSystemType.String);
			c.PropertyName = TSUserInfoMetadata.PropertyNames.CreatedBy;
			c.CharacterMaxLength = 40;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSUserInfoMetadata.ColumnNames.CreatedTime, 7, typeof(System.DateTime), esSystemType.DateTime);
			c.PropertyName = TSUserInfoMetadata.PropertyNames.CreatedTime;
			c.HasDefault = true;
			c.Default = @"(getdate())";
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSUserInfoMetadata.ColumnNames.LastUpdatedBy, 8, typeof(System.String), esSystemType.String);
			c.PropertyName = TSUserInfoMetadata.PropertyNames.LastUpdatedBy;
			c.CharacterMaxLength = 40;
			m_columns.Add(c);
				
			c = new esColumnMetadata(TSUserInfoMetadata.ColumnNames.LastUpdatedTime, 9, typeof(System.DateTime), esSystemType.DateTime);
			c.PropertyName = TSUserInfoMetadata.PropertyNames.LastUpdatedTime;
			c.HasDefault = true;
			c.Default = @"(getdate())";
			m_columns.Add(c);
				
		}
		#endregion	
	
		static public TSUserInfoMetadata Meta()
		{
			return meta;
		}	
		
		public Guid DataID
		{
			get { return base.m_dataID; }
		}	
		
		public bool MultiProviderMode
		{
			get { return false; }
		}		

		public esColumnMetadataCollection Columns
		{
			get	{ return base.m_columns; }
		}
		
		#region ColumnNames
		public class ColumnNames
		{ 
			 public const string UserID = "UserID";
			 public const string ThirdUnitID = "ThirdUnitID";
			 public const string UserName = "UserName";
			 public const string DeptNo = "DeptNo";
			 public const string Manager = "Manager";
			 public const string Email = "Email";
			 public const string CreatedBy = "CreatedBy";
			 public const string CreatedTime = "CreatedTime";
			 public const string LastUpdatedBy = "LastUpdatedBy";
			 public const string LastUpdatedTime = "LastUpdatedTime";
		}
		#endregion	
		
		#region PropertyNames
		public class PropertyNames
		{ 
			 public const string UserID = "UserID";
			 public const string ThirdUnitID = "ThirdUnitID";
			 public const string UserName = "UserName";
			 public const string DeptNo = "DeptNo";
			 public const string Manager = "Manager";
			 public const string Email = "Email";
			 public const string CreatedBy = "CreatedBy";
			 public const string CreatedTime = "CreatedTime";
			 public const string LastUpdatedBy = "LastUpdatedBy";
			 public const string LastUpdatedTime = "LastUpdatedTime";
		}
		#endregion	

		public esProviderSpecificMetadata GetProviderMetadata(string mapName)
		{
			MapToMeta mapMethod = mapDelegates[mapName];

			if (mapMethod != null)
				return mapMethod(mapName);
			else
				return null;
		}
		
		#region MAP esDefault
		
		static private int RegisterDelegateesDefault()
		{
			// This is only executed once per the life of the application
			lock (typeof(TSUserInfoMetadata))
			{
				if(TSUserInfoMetadata.mapDelegates == null)
				{
					TSUserInfoMetadata.mapDelegates = new Dictionary<string,MapToMeta>();
				}
				
				if (TSUserInfoMetadata.meta == null)
				{
					TSUserInfoMetadata.meta = new TSUserInfoMetadata();
				}
				
				MapToMeta mapMethod = new MapToMeta(meta.esDefault);
				mapDelegates.Add("esDefault", mapMethod);
				mapMethod("esDefault");
			}
			return 0;
		}			

		private esProviderSpecificMetadata esDefault(string mapName)
		{
			if(!m_providerMetadataMaps.ContainsKey(mapName))
			{
				esProviderSpecificMetadata meta = new esProviderSpecificMetadata();			


				meta.AddTypeMap("UserID", new esTypeMap("numeric", "System.Decimal"));
				meta.AddTypeMap("ThirdUnitID", new esTypeMap("numeric", "System.Decimal"));
				meta.AddTypeMap("UserName", new esTypeMap("nvarchar", "System.String"));
				meta.AddTypeMap("DeptNo", new esTypeMap("nvarchar", "System.String"));
				meta.AddTypeMap("Manager", new esTypeMap("nvarchar", "System.String"));
				meta.AddTypeMap("Email", new esTypeMap("varchar", "System.String"));
				meta.AddTypeMap("CreatedBy", new esTypeMap("varchar", "System.String"));
				meta.AddTypeMap("CreatedTime", new esTypeMap("datetime", "System.DateTime"));
				meta.AddTypeMap("LastUpdatedBy", new esTypeMap("varchar", "System.String"));
				meta.AddTypeMap("LastUpdatedTime", new esTypeMap("datetime", "System.DateTime"));			
				
				
				
				meta.Source = "T_S_UserInfo";
				meta.Destination = "T_S_UserInfo";
				
				meta.spInsert = "proc_T_S_UserInfoInsert";				
				meta.spUpdate = "proc_T_S_UserInfoUpdate";		
				meta.spDelete = "proc_T_S_UserInfoDelete";
				meta.spLoadAll = "proc_T_S_UserInfoLoadAll";
				meta.spLoadByPrimaryKey = "proc_T_S_UserInfoLoadByPrimaryKey";
				
				this.m_providerMetadataMaps["esDefault"] = meta;
			}
			
			return this.m_providerMetadataMaps["esDefault"];
		}

		#endregion

		static private TSUserInfoMetadata meta;
		static protected Dictionary<string, MapToMeta> mapDelegates;
		static private int _esDefault = RegisterDelegateesDefault();
	}
}
